package hello.entity;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.stream.Collectors;

public class CardDefiniteEntity {

	private final ArrayList<String> cardList = new ArrayList<String>();
	private final ArrayList<String> usedCardList = new ArrayList<String>();
	
	String[] cards = {
			"A1","A2","A3","A4","A5","A6","A7","A8","A9","A10","A11","A12","A13",
			"B1","B2","B3","B4","B5","B6","B7","B8","B9","B10","B11","B12","B13",
			"C1","C2","C3","C4","C5","C6","C7","C8","C9","C10","C11","C12","C13",
			"D1","D2","D3","D4","D5","D6","D7","D8","D9","D10","D11","D12","D13"
			
			
	};
	
	void init() {
		for(int i = 0; i < cards.length; i++) {
			cardList.add(cards[i]);
		}
	}
	
	public CardDefiniteEntity() {
		init();
	}
	
	
	public void clearAndReadInitCardList() {
		cardList.clear();
		init();
	}
	
	
	public List<String> getThirtyCard() {
		synchronized (cardList) {
			if(cardList.size() == 0) {
				return null;
			}			
			List<String> card = new ArrayList<>();
			Random random = new Random();			
			for(int i = 0; i < 13; i++) {
				int next = cardList.size() > 1 ? random.nextInt(cardList.size() - 1) : 0;
				card.add(cardList.get(next));
				cardList.remove(cardList.get(next));
			}
			return card;
		}
		
	}
	
	
}
